﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace Core.Framework.Model.Common
{
    /// <summary>
    /// 注册服务商
    /// </summary>
    public class BuildServiceProvider
    {

        public static ServiceCollection serviceCollection { get; } = new ServiceCollection();

        /// <summary>
        /// 获取服务
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="model"></param>
        /// <returns></returns>
        public static T GetService<T>(T model = null) where T : class
        {
            return serviceCollection
                .BuildServiceProvider()
                .GetService<T>();
        }
    }
}
